/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			ETSI_Rows.h
  \date			september 2011
  \author		TNick

  \brief		Contains the definition for ETSI_Rows class


  Copyright (c) 2011, Nicu Tofan
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
 * Neither the name of the copyright holder nor the
   names of its contributors may be used to endorse or promote products
   derived from this software without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL NICU TOFAN BE LIABLE FOR ANY
 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __ETSI_ROWS_INC__
#define __ETSI_ROWS_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<sheet/subitems/ETSI_Root.h>

#include	<sheet/ETSubItem.h>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

/// sub-item able to display any number of rows, each of wich with multiple sub-items
/**
*
*/
class ETSI_Rows : public ETSubItem 		{

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

protected:

	/// header that groups all ETSI_Root items (one for each row)
	ETSI_Root		ctr_block;


	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:

	/// constructor;
	ETSI_Rows		( void );

	/// destructor;
	virtual				~ETSI_Rows		( void );


	/// set the vertical alignment size (distance between two consecutive rows)
	inline void			setVAlignSize	(qreal sz)
	{ ctr_block.setPosX(sz); }


	/// get the height of the sign; the height is twice the width
	inline qreal		vAlignSize		(void)
	{ return ctr_block.posX(); }


	/// compute the size of the sign based on current font
	void				recalcVAlign		(void);


	/// return first row
	ETSI_Root *			first				(void)
	{ return static_cast<ETSI_Root *>(ctr_block.first()); }

	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
	/** @name Dimensions. Bounding box.    */
	//@{
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */


	/// get the bounding box of this item
	/**
	  *	The function may or may not honor the flags representing the "dirty"
	  *	state of that item regarding it's characteristics depending on
	  *	\b b_full argument (when true the flags are ignored)
	  */
	void				recompute		(bool b_full);


	//@}
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */





	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
	/** @name Others    */
	//@{
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */


	/// paint the element on provided surface
	void		paint			(
			ETSheetView *	vp,
			QPainter *		painter,
			QPointF			pt_ref
			);

	//@}
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */




	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
	/** @name Navigation    */
	//@{
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */


	/// used by kids to request a move up
	/**
		*	If the parent can't move the selection as there is no
		*	kid above the caller, it should return false
		*/
	bool		kidNavReq_up		(ETSheetView * vp, ETSubItem * kid);


	/// used by kids to request a move down
	/**
		*	If the parent can't move the selection as there is no
		*	kid below the caller, it should return false
		*/
	bool		kidNavReq_down		(ETSheetView * vp, ETSubItem * kid);


	//@}
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */




	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
	/** @name Others    */
	//@{
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */

protected:

	/// called to determine the sub-item that was hit
	void		hitTest		(HtData * h_data);


public:

	/// identifies the type of the sub-item
	SIType		type		( void ) const { return TYROWS;}


	QPointF		subIRefPt	(const ETSubItem * p_kid) const;


	//@}
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */



	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
	/** @name Save and load	*/
	//@{
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */

public:




	/// creates a new item based on DOM element's content
	/**
	*	It is the responsability of the caller to properly insert resulted
	*	sub-item in a chain.
	*
	*	@return either the item that was initialised or NULL for errors
	*/
	static ETSI_Rows *		loadXML			(
		QDomElement		dom_e	/**< data source */
		);


	/// saves the properties of this item to provided DOM element
	/**
	*	Internally, the inherited class needs to call saveXMLCmn()
	*	to save common properties hosted by the ETSubItem class
	*/
	void					saveXML			(
		QDomElement		dom_e
		);

protected:

	/// performs basic steps and may be used by inheritants
	void			loadXMLBasic		(
		QDomElement		dom_e
		);

	/// performs basic steps and may be used by inheritants
	void			saveXMLBasic		(
		QDomElement		dom_e
		);



	//@}
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */


	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class ETSI_Rows	*/

/*  CLASS    =============================================================== */
//
//
//
//
#endif // __ETSI_ROWS_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
